import Vue from 'vue'
import App from './App'

//引入网络请求api
import http from './util/api.js'

const base_url = 'http://farm.shkj.pro'
Vue.prototype.$base_url = base_url

const msg = (title, duration=1500, mask=false, icon='none')=>{
	//统一提示方便全局修改
	if(Boolean(title) === false){
		return;
	}
	uni.showToast({
		title,
		duration,
		mask,
		icon
	});
}


//时间戳过滤器
Vue.filter('formatDate',(date,time)=>{
	const nDate = new Date(date*1000)
	const year = nDate.getFullYear()
	const month = (nDate.getMonth()+1).toString().padStart(2,0)
	const day = nDate.getDate().toString().padStart(2,0)
	const hour = nDate.getHours().toString().padStart(2,0)
	const minute = nDate.getMinutes().toString().padStart(2,0)
	const second = nDate.getSeconds().toString().padStart(2,0)
	 if(time&&time.toLowerCase() === 'yyyy-mm-dd'){
	                    return `${year}-${month}-${day}`;
	                }else if(time&&time.toLowerCase() === 'hh:mm:ss'){
	                    return `${hour}:${minute}:${second}`;
	                }else{
	                    return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
	                }
}) 

Vue.config.productionTip = false
Vue.prototype.http = http
Vue.prototype.$api = {msg};

App.mpType = 'app'

const app = new Vue({
    ...App
})
app.$mount()
